<?
//引入所有子系统信息
include_once("../../../common/model/extender_import.php");

    //**获取当前板块资料，必然载入，后续很多读取板块数据库的表格，都写成动态的了。
    $_plate=$plate['order'];


$system_part = 'order';


//这个需要放在开头，不然set condition会失效
    if(!$_REQUEST['lessequal_ondate']){
        $_REQUEST['lessequal_ondate'] = date("Y-m-d", strtotime("+4 days"));
    }
    if(!$_REQUEST['greaterequal_ondate']){
        //+7日
        $_REQUEST['greaterequal_ondate']=date("Y-m-d");
    }


    $less_enddate     =$_REQUEST['lessequal_ondate'];
    $greater_startdate=$_REQUEST['greaterequal_ondate'];

    //计算出这两个日期及其之间的日期，输出一个字符串，用','隔开
    $less_enddate = $_REQUEST['lessequal_ondate'];
    $greater_startdate = $_REQUEST['greaterequal_ondate'];

    // 创建 DateTime 对象
    $start = new DateTime($greater_startdate);
    $end = new DateTime($less_enddate);
    // 用于存储日期的数组
    $dates = [];
    // 循环获取两个日期之间的所有日期
    while ($start <= $end) {
        $dates[] = $start->format('Y-m-d 00:00:00'); // 按年-月-日格式存储日期
        $start->modify('+1 day'); // 日期加 1 天
    }

    // 将日期数组用','连接成字符串
    $day_period = implode("','", $dates);




    //**获取板块的设置，必然载入
    include_once("../model/setting.php");


    //根据筛选框传递过来的内容，组装查找语句
    include_once("script/set_condition.php");



    //根据页面数量信息，筛选信息，创造url，供页码使用
    include_once("script/set_url.php");
    include_once("script/set_order.php");


    //获取时间端内所有订单详情数据
    //$detail=select_lines_all_items($table_prefix."order_detail",$sort,$_condition,"");



    //print_r2($detail);

    $school_list=select_lines_all_items($table_prefix."department","nid desc","parent_id = 0 and (status != '已删除' or status is null)","");


    //循环，查找数据库中，parent_nid = 当前的 nid的值
    foreach($school_list as $key=>$value){

        //查找学校下面的所有班
        $school_list[$key][$value['name']]=select_lines_all_items($table_prefix."department",
            "FIELD(name, '一年级', '二年级', '三年级', '四年级', '五年级', '六年级'),name asc",
            "parent_id = '{$value['nid']}' and (status != '已删除' or status is null) ","");

        //循环，$school_list[$key]['grade'] 的数据，查找数据库中，parent_nid = 当前的 nid的值，记录在class
        foreach($school_list[$key][$value['name']] as $k=>$v){
            $school_list[$key][$value['name']][$k][$v['name']]=select_lines_all_items($table_prefix."department",
                "name asc","parent_id = '{$v['nid']}' and (status != '已删除' or status is null)","");
        }
    }




    //循环查找学校的所有订单
    foreach($school_list as $key=>$value) {
        //获取时间端内所有订单详情数据
        $detail[$value['name']] = select_lines_items($table_prefix . "order_detail", $sort,
                                                     "nid,name,status,product_name",
                                                     $_condition."and status= '正常' and school = '{$value['name']}'", "");

    }



    $week_map = array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");


?>

